# coding:utf8
from django.conf.urls import url
from django.urls import path, include
from rest_framework.routers import DefaultRouter, SimpleRouter

from BookTest import form_view
from . import old_views
from . import views

app_name = "BookTest"
router = SimpleRouter()
router.register(r'books', views.BookInfoViewSet, base_name='book')
urlpatterns = [
    # url(r'^booktest/$', old_views.IndexView.as_view()),
    # url(r'books/$', views.BooksAPIView.as_view()),
    # url(r'^$', views.index),
    # url(r'books/(?P<pk>\d+)/$', views.BookAPIView.as_view()),

    # url(r'^books/$', views.BookListView.as_view()),
    # path(r'books/', views.BookListView.as_view()),
    # path('books/update/<pk>/', views.BookChangeView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views.BookDetailView.as_view()),
    # path('books/change/<pk>/', views.BookGetChangeView.as_view()),
    # path('books/all/<pk>/', views.BookIndexView.as_view()),

    # path('books/', views.BookInfoViewSet.as_view({'get': 'list'})),
    # path('books/<pk>/', views.BookInfoViewSet.as_view({'get': 'retrieve'})),
    # path('books/latest/', views.BookInfoViewSet.as_view({'get': 'latest'})),
    # path('books/<pk>/read/', views.BookInfoViewSet.as_view({'put': 'read'})),
    # path('city/', form_view.IndexView.as_view()),
    path('', include(router.urls))
]
# rest framework中路由 组件有两种添加方式:
# 1.urlpatterns += router.urls
# 2.path('', include(router.urls))
# urlpatterns += router.urls
